﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;

public partial class Agency_companyTB_Goods : System.Web.UI.Page
{
    
    public int projectid;
    public string UserCode_TB;
    protected void Page_Load(object sender, EventArgs e)
    {

        //if (HZ.MBSM.BLL.Login.CheckAssert(this.UseAccountType))
        //{
            projectid = SysFun.ToInt(SysFun.IsSQL(Request.QueryString["projectid"]));
            UserCode_TB=SysFun.IsSQL(SysFun.ToTrim(Request.QueryString["UserCode_TB"]));


            switch (projectid.ToString())
            {
                case "8":
                    GridView1.Columns[8].HeaderText = "中标价";
                    GridView1.Columns[9].HeaderText = "最高零售价";
                    break;
                case "9":
                    GridView1.Columns[8].HeaderText = "最高零售价";
                    GridView1.Columns[9].Visible = false;
                    break;
                case "10":
                    GridView1.Columns[8].HeaderText = "最高限价";
                    GridView1.Columns[9].HeaderText = "最高零售价";
                    break;
                case "11":
                    GridView1.Columns[8].Visible = false;
                    GridView1.Columns[9].Visible = false;
                    break;
                case "12":
                    GridView1.Columns[8].HeaderText = "最高零售价";
                    GridView1.Columns[9].Visible = false;
                    break;

            }
            GridView1.Columns[0].Visible = true;
            showGridView();
            GridView1.Columns[0].Visible = false;


        //}

    }

    /// <summary>
    /// 数据绑定
    /// </summary>
    public void showGridView()
    {

        //0 原中标商品 1 自行采购  2  22种降价 3 人血蛋白 4 重点监控 默认为‘0’
        string strConditions = "";
        strConditions = fctConditions();
        Db db = new Db();
        DbPage dbPage = new DbPage(db);
        dbPage.Table = "SupplyPlan_Goods";                                               //要查询的表明
        dbPage.Key = "SupplyGoodsId";                                          //表的主键    
        dbPage.Where = strConditions;                                           //查询条件    
        dbPage.SelectField = "unit,Factor,SupplyGoodsId,projectid,productcode,ProductName,MedicineModel,Convert(numeric(20,2),RetailPrice) as RetailPrice,Outlookc,GoodsId,CompanyName_PS,CompanyName_SC,CompanyName_TB,Convert(numeric(20,2),BidPrice) as BidPrice,IsUse,pack,GoodsName,CASE QualityLevels " + ConfigurationManager.AppSettings["QualityLevels"].ToString() + " END AS QualityLevels,case GoodsState when '0' then '原中标' when '1' then '自行采购' when '2' then '22种降价' when '3' then '血液制品' when '4' then '重点监控' end as goodsstate";//要显示的字段
        dbPage.PageIndex = SysFun.ToInt(Request["CurrentlyPageIndex"]);          //要显示第几页   
        
            dbPage.PageSize = 15;                                                    //没有显示记录条数   
       
        dbPage.OrderBy = "CompanyName_SC,ProductName";                  //排序字段
        System.Data.IDataReader dr = dbPage.ExecuteReader();
        GridView1.DataSource = dr;
        GridView1.DataBind();
        dr.Close();
        dr.Dispose();
        dbPage.Db.Close();
        db.Close();
        this.DbPageFlip1.DbPage = dbPage;//将数据传给控键

    }
    public string  fctConditions()
    {
        string strmap="";
        strmap = " projectid=" + projectid.ToString() + " and UserCode_TB='" + UserCode_TB.ToString() + "' and isuse=1";
        return strmap;
    }

    /// <summary>
    /// 生成查询条件
    /// </summary>
    /// <returns></returns>
  
  
   
}
